home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / win / pascal / bmhelp.exe / BMHELP.PAS
Encoding:
Pascal/Delphi Source File  |  1991-09-17  |  2.7 KB  |  105 lines

  1. {************************************************}
  2. {  A Demo Program to load Icons onto the Screen  }
  3. {                                                }
  4. {************************************************}
  5.  
  6. program MyProgram;
  7.  
  8. uses WinTypes, WinProcs, WObjects;
  9. {$R bitmaps.res}
  10.  
  11. type
  12.   TMyApplication = object(TApplication)
  13.     procedure InitMainWindow; virtual;
  14.   end;
  15.  
  16. TYPE
  17.   MyLong = RECORD
  18.     CASE Integer OF
  19.       0: (TheLong:LongInt);
  20.       1: (Lo: Word;
  21.           Hi: Word);
  22.   END;
  23.  
  24. type
  25.   PMyWindow = ^TMyWindow;
  26.   TMyWindow = object(TWindow)
  27.     PROCEDURE MakeBrush(Var Msg:TMessage);Virtual;
  28.     Constructor Init(AParent : PwindowsObject; Atitle: PChar);
  29.     function CanClose: Boolean; virtual;
  30.     procedure WMLButtonDown(var Msg: TMessage);
  31.       virtual wm_First + wm_LButtonDown;
  32.     procedure WMRButtonDown(var Msg: TMessage);
  33.       virtual wm_First + wm_RButtonDown;
  34.   end;
  35.  
  36. {--------------------------------------------------}
  37. { TMyWindow's method implementations:              }
  38. {--------------------------------------------------}
  39.  
  40. function TMyWindow.CanClose: Boolean;
  41. var
  42.   Reply: Integer;
  43. begin
  44.   CanClose := True;
  45. end;
  46.  
  47. procedure TMyWindow.WMLButtonDown(var Msg: TMessage);
  48. begin
  49.   MessageBox(HWindow, 'You have pressed the left mouse button',
  50.     'Message Dispatched', mb_Ok);
  51. end;
  52.  
  53. procedure TMyWindow.WMRButtonDown(var Msg: TMessage);
  54. begin
  55.   MessageBox(HWindow, 'You have pressed the right mouse button',
  56.     'Message Dispatched', mb_Ok);
  57. end;
  58.  
  59. Constructor TMyWindow.Init(Aparent: PwindowsObject; ATitle: PChar);
  60. VAR
  61.  ALong : MyLong;
  62. BEGIN
  63.   TWindow.Init(Aparent, ATitle);
  64.   Attr.Menu := LOadMenu(Hinstance, PChar(100));
  65.   ALong.Lo := LoadBitmap(Hinstance, PChar(501));
  66.   ModifyMenu(Attr.Menu, 101, mf_ByCommand or mf_Bitmap, 101,
  67.        PChar(Along.TheLong));
  68. End;
  69.  
  70.  
  71. PROCEDURE TMyWindow.MakeBrush;
  72. {Copied from TPW Windows Programing Guide Pg 279}
  73. VAR
  74.   MyLogBrush : TLogBrush;
  75.   HMyBit     : MyLong;
  76. BEGIN
  77.   HMyBit.Lo := LoadBitmap(HInstance,'pryamid');
  78.   MyLogBrush.lbStyle := bs_Pattern;
  79.   MyLogBrush.lbHatch := HMyBit; {Type mismatch on this line}
  80.   TheBrush := CreateBrushIndirect(@MyLogBrush);
  81. END;
  82.  
  83.  
  84. {--------------------------------------------------}
  85. { TMyApplication's method implementations:         }
  86. {--------------------------------------------------}
  87.  
  88. procedure TMyApplication.InitMainWindow;
  89. begin
  90.   MainWindow := New(PMyWindow, Init(nil, 'Sample ObjectWindows Program'));
  91. end;
  92.  
  93. {--------------------------------------------------}
  94. { Main program:                                    }
  95. {--------------------------------------------------}
  96.  
  97. var
  98.   MyApp: TMyApplication;
  99.  
  100. begin
  101.   MyApp.Init('MyProgram');
  102.   MyApp.Run;
  103.   MyApp.Done;
  104. end.
  105.